package com.gopay.bis.service.bank.impl.certify;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gopay.bis.common.util.BankLogUtils;
import com.gopay.common.Result;
import com.gopay.common.constants.bank.BankConstants;
import com.gopay.common.constants.bank.BankOrderType;
import com.gopay.common.constants.bank.BisBankBusinessProd;
import com.gopay.common.constants.bank.BisBankInterfaceChannel;
import com.gopay.common.constants.proccode.ProcCodeConstants;
import com.gopay.common.domain.bank.ExPayBaseMessage;
import com.gopay.common.util.spring.SpringContextUtil;
import com.gopay.remote.bank.ExPayInteractRemoteService;
import com.gopay.remote.bank.foundation.BankCardCertifyRemoteService;

/** 
 * @ClassName: IpayCertifyServiceImpl 
 * @Description: 民生i支付鉴权
 * @author ShenJun 
 * @date 2017年6月15日 上午10:58:33  
 */

public class CmbcAdpayCertifyServiceImpl implements BankCardCertifyRemoteService {

	private Logger logger = LoggerFactory.getLogger(CmbcAdpayCertifyServiceImpl.class);
	/* (非 Javadoc) 
	 *  
	 *  
	 * @param base
	 * @return 
	 * @see com.gopay.remote.bank.foundation.BankCardCertifyRemoteService#mobileCertify(com.gopay.common.domain.bank.foundation.IdentityInfoMessage) 
	 */
	@Override
	public Result bankCardCertify(ExPayBaseMessage base) {
		logger.error("CmbcAdpayCertifyServiceImpl.bankCardCertify  民生代扣鉴权   start----- ");
		Result result = new Result(false);
		try {
			String outStlmCd = BankConstants.BANK_LOGO_CMBCADPAY; // 默认走民生通道
	        base.setOutStlmCd(outStlmCd);
	        base.setBankIntrChann(BisBankInterfaceChannel._11);
	        // 因有些产品线调用时没有传该字段，会导致民生代扣插入时报空指针
	        if (null == base.getBankBusProd()) {
	            base.setBankBusProd(BisBankBusinessProd._19);
	        }
	        base.setBankOrderType(BankOrderType.GOPAY_BIS_ORDER);// 订单类型：新平台订单
	        String beanName = outStlmCd + "-" + "EXPAY";
	        ExPayInteractRemoteService exPayService = (ExPayInteractRemoteService) SpringContextUtil.getBean(beanName);
			result = exPayService.certification(base);
			logger.error("CmbcAdpayCertifyServiceImpl.bankCardCertify  民生代扣鉴权   end----- ");
		} catch (Exception e) {
			logger.error("CmbcAdpayCertifyServiceImpl.bankCardCertify  民生代扣鉴权   exception----- ");
			BankLogUtils.printServiceImplExceptionLog(e);
            result.setResultCode(ProcCodeConstants.PROC_CODE_100E6076);
		}
		return result;
	}

}
